package com.fjnu.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.fjnu.dao.IBorrowDao;
import com.fjnu.dao.common.BaseDaoImpl;
import com.fjnu.dao.common.DaoException;
import com.fjnu.entities.Borrow;
import com.fjnu.entities.User;
@Repository
public class BorrowDao extends BaseDaoImpl<Borrow> implements IBorrowDao {

	@Override
	public void addBorrow(Borrow borrow) {
		save(borrow);
	}

	@Override
	public void updateBorrow(Borrow borrow) {
		update(borrow);
	}

	@Override
	public void delBorrow(Integer id) {
		delete(id);
	}

	@Override
	public List<Borrow> findBorrowByBUser(User borrowUser) {
		String idnumber=borrowUser.getIdnumber();
		String hql="from Borrow b where b.borrowPerson.idnumber=?";
		List<Borrow> list = findByHQL(hql, idnumber);
		return list;
	}

	@Override
	public List<Borrow> findBorrowForEUser(String status) {
		String hql="from Borrow b where b.status = ?";
		List<Borrow> list =findByHQL(hql,status);
		return list;
	}
	public Borrow findUniqueBorrow(Integer id) {
		// TODO Auto-generated method stub
		return findById(id);
	}

}
